CSharpTest.Net
Password Constructor(Boolean,Byte[])
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > Password Class > Password Constructor : Password Constructor(Boolean,Byte[])

clear
bytes

Glossary Item Box

Creates the password from the given bytes and salt

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal clear As Boolean, _
   ByVal bytes() As Byte _
)
C# 
public Password( 
   bool clear,
   byte[] bytes
)

Parameters

clear
bytes

Example

Library/Library.Test/TestPassword.cs

C#Copy Code
const int count = 1000;
Random rand = new Random();
byte[] bytes = new byte[100];
rand.NextBytes(bytes);
Stopwatch time = new Stopwatch();
time.Start();

for (int i = 0; i < count; i++)
{
    bytes = new byte[rand.Next(450) + 50];
    rand.NextBytes(bytes);
    using (Password pwd = new Password(false, bytes))
    {
        byte[] copy = IOStream.ReadAllBytes(pwd.ReadBytes());
        Assert.AreEqual(bytes, copy);
    }
}
time.Stop();
Trace.WriteLine(time.Elapsed.ToString(), count.ToString() + " Passwords");
VB.NETCopy Code
Const  count As Integer = 1000
Dim rand As New Random()
Dim bytes As Byte() = New Byte(100) {}
rand.NextBytes(bytes)
Dim time As New Stopwatch()
time.Start()

Dim i As Integer = 0
While i < count
    bytes = New Byte(rand.[Next](450) + 50) {}
    rand.NextBytes(bytes)
    Using pwd As New Password(False, bytes)
        Dim copy As Byte() = IOStream.ReadAllBytes(pwd.ReadBytes())
        Assert.AreEqual(bytes, copy)
    End Using
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
time.[Stop]()
Trace.WriteLine(time.Elapsed.ToString(), count.ToString() + " Passwords")

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys